all: rebootex bin2c update_rebootex clean

BIN=$(shell psp-config --pspdev-path)/bin
INCLUDE=$(shell psp-config --pspsdk-path)/include

CC = $(BIN)/psp-gcc
ASM = $(BIN)/psp-as

CFLAGS = -D PSP -I $(INCLUDE) -W -Wall -G0 -fno-pic -mno-abicalls -w

rebootex:
	$(CC) $(CFLAGS) -S main.c -o main.s
	$(ASM) main.s -o main.o
	$(BIN)/psp-ld -T linkfile.l main.o -o main.elf
	$(BIN)/psp-strip -s main.elf
	$(BIN)/psp-objcopy -O binary main.elf rebootex.bin

bin2c:
	bin2c rebootex.bin rebootex.h rebootex

update_rebootex:
	cp rebootex.h ../ofwloader_kernel/rebootex.h

clean:
	rm -rf *~ *.o *.elf *.s